﻿namespace Digitalmes.Application.Sys.Orgs.Queries;

/// <summary>
/// 查询机构命令。
/// </summary>
public record GetOrgListQuery : IRequest<IResult<List<SysOrgDto>>>;

internal sealed class GetOrgListQueryHandler(IRepository<SysOrg> repo) : IRequestHandler<GetOrgListQuery, IResult<List<SysOrgDto>>>
{
    public async Task<IResult<List<SysOrgDto>>> Handle(GetOrgListQuery request, CancellationToken cancellationToken)
    {
        var items = await repo.GetListAsync(cancellationToken);
        return Result.From(items.Adapt<List<SysOrgDto>>());
    }
}
